<template>
  <div v-if="config" class="qbe-search-box">
    <div class="divider-empty-thin"></div>
    <span class="title">
      {{ $srv.getI18nByPath('oSetupPanel.SetupAttrDetail.QBEsearch') }}
    </span>
    <div class="qbe-query">
      <div class="label-value">
        <span>{{ $srv.getI18nByValue('QBE查询') }}</span>
        <vxe-switch
          v-model="config.enable"
          :disabled="!isMain"
          size="default"
          open-label="启用"
          close-label="禁用"
          @change="saveDetailToConfig"
        ></vxe-switch>
      </div>
      <div class="db-label-value">
        <div class="label-value">
          <span>{{ $srv.getI18nByValue('初始显示') }}</span>
          <vxe-switch
            v-model="config.isInitShow"
            :disabled="!config.enable"
            size="default"
            @change="saveDetailToConfig"
          ></vxe-switch>
        </div>
        <div class="label-value">
          <span>{{ $srv.getI18nByValue('初始间距') }}</span>
          <InputNumber
            :max="50"
            :min="1"
            v-model="config.initSpace"
            :formatter="value => `${value}%`"
            :parser="value => value.replace('%', '')"
          />
        </div>
      </div>
      <div class="label-value">
        <span>{{ $srv.getI18nByValue('位置') }}</span>
        <vxe-radio-group
          v-model="config.position"
          :disabled="!config.enable"
          @change="saveDetailToConfig"
        >
          <vxe-radio label="top" content="上"></vxe-radio>
          <vxe-radio label="bottom" content="下"></vxe-radio>
          <vxe-radio label="left" content="左"></vxe-radio>
          <vxe-radio label="right" content="右"></vxe-radio>
        </vxe-radio-group>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Prop, Watch, Model, Vue } from 'vue-property-decorator';
import { Tsrv, T_srv } from '@/services';

@Component
export default class qbeSearchSetting extends Vue {
  @Model('modelchange') config: any;

  @T_srv.prop({ required: false, default: false }) isMain: boolean;

  created() {}

  mounted() {}

  private saveDetailToConfig() {
    this.$emit('modelchange', this.config);
    this.$emit('change');
  }
}
</script>

<style scoped lang="scss">
.qbe-search-box {
  position: relative;
  .title {
    font-weight: bold;
    height: 36px;
    display: block;
    line-height: 36px;
  }
  .qbe-query {
    display: flex;
    flex-direction: column;
    margin-left: 10px;
    .db-label-value {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
    }
  }
  .label-value {
    margin-bottom: 5px;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    & > span {
      white-space: nowrap;
      &::after {
        content: '：';
        margin: 0 5px;
      }
    }
  }
}
</style>
